package agent;

import java.util.ArrayList;

import processing.core.*;

public class Main extends PApplet {
	
	ArrayList<Agent> agents;
	PFont pf;
	
	public void setup() {
		size(1024,768);
		agents = new ArrayList<Agent>();
		for (int i = 0; i < 5; i++) agents.add(new TestAgent(this));
		pf = createFont("Arial", 30);
	}
	
	public void draw() {
		colorMode(HSB);
		textFont(pf);
		noStroke();
		background(0);
		for (int i = 0; i < agents.size(); i++) {
			((Agent) agents.get(i)).draw();
		}
		fill(255);
		text(frameRate, width - 150, height - 20);
	}
	
	public ArrayList<Agent> getNeighbors(Agent a, float radius) {
		ArrayList<Agent> nearAgents = new ArrayList<Agent>();
		PVector curPos = a.getCurrentPosition();
		for (int i = 0; i < agents.size(); i++) {
			Agent testAgent = agents.get(i);
			if (!a.equals(testAgent)) {
				if (PVector.dist(curPos, testAgent.getCurrentPosition()) < radius) nearAgents.add(testAgent);
			}
		}
		return nearAgents;
	}
	
	public void addAgent(Agent a) {
		agents.add(a);
	}
}
